package com.test.day03.method01;

import java.io.File;

/**
 * @program: 遍历所有文件夹或目录
 * @author: luhd
 * @create: 2021-08-01
 */
public class Demo06File {
    public static void main(String[] args) {
        show01(); // 不含路径
        show02(); // 含路径
    }

    private static void show01() {
        File file = new File("D:\\myProject\\javaTest");
        String[] arr = file.list();
        for (String fileName : arr) {
            System.out.println(fileName);
        }
    }

    private static void show02() {
        File file = new File("D:\\myProject\\javaTest");
        File[] files = file.listFiles();
        for (File f : files) {
            System.out.println(f);
        }
    }
}
